package extractLatAndLon;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;

public class extractGuassianLatAndLon {

	public static void main(String[] args) {
		String inFilePath = "gaussianGeo.txt";
		String latPath = "geoLat.txt";
		String lonPath = "geoLon.txt";
		File inFile = new File(inFilePath);
		File outputLatFile = new File(latPath);
		File outputLonFile = new File(lonPath);
		try {
			FileReader inReader = new FileReader(inFile.getAbsolutePath());
			FileWriter latWriter = new FileWriter(outputLatFile.getAbsolutePath(), true);
			FileWriter lonWriter = new FileWriter(outputLonFile.getAbsolutePath(), true);
			BufferedReader bReader = new BufferedReader(inReader);
			BufferedWriter blatWriter = new BufferedWriter(latWriter);
			BufferedWriter blonWriter = new BufferedWriter(lonWriter);
			String aLine = "";
			while ((aLine = bReader.readLine()) != null) {
				blatWriter.write(aLine.substring(0, aLine.indexOf(",")) + "\n");
				blonWriter.write(aLine.substring(aLine.indexOf(",") + 1, aLine.length()) + "\n");
				blatWriter.flush();
				blonWriter.flush();
			}
			bReader.close();
			blatWriter.close();
			blonWriter.close();
			inReader.close();
			latWriter.close();
			lonWriter.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
